#lang racket


(require "coord.rkt"
         "lang.rkt"
         "math.rkt")

(provide box-corners
         box-corners-p
         box-corners-pp)


(define (box-corners width length height)
  (let ((width (/2 width))
        (length (/2 length))
        (height (/2 height)))
    (list
     (xyz (- width) length (- height))
     (xyz (- width) (- length) (- height))
     (xyz width (- length) (- height))
     (xyz width length (- height))
     (xyz (- width) length height)
     (xyz (- width) (- length) height)
     (xyz width (- length) height)
     (xyz width length height))))

(define (box-corners-p p width length height)
  (map (cλ add-c p) (box-corners width length height)))

(define (box-corners-pp min-p max-p)
  (let ((d (sub-c max-p min-p)))
    (box-corners-p (midcoord min-p max-p) (abs (xyz-x d)) (abs (xyz-y d)) (abs (xyz-z d)))))